import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core';

class TransitionModel extends PolylineEdgeModel {
  static extendKey = 'TransitionModel';
  getEdgeStyle(): {
    [x: string]: any;
    fill?: string;
    stroke?: string;
    strokeWidth?: number;
  } {
    const style = super.getEdgeStyle();
    if (this.properties.state === 'active') {
      style.stroke = '#00ff00';
    } else if (this.properties.state === 'history') {
      style.stroke = '#ff0000';
    }
    return style;
  }
}

class TransitionView extends PolylineEdge {
  static extendKey = 'TransitionEdge';
}

const Transition = {
  type: 'wlf:transition',
  view: TransitionView,
  model: TransitionModel,
};

export { TransitionView, TransitionModel };
export default Transition;
